﻿namespace GoodAdmin.System;

public class ExcelExtService : IExcelExtService, ITransient
{
    private readonly IFileService _fileService;

    public ExcelExtService(IFileService fileService)
    {
        _fileService = fileService;
    }
    public async Task<List<Entity>> ReadExcelToList<Entity>(IFormFile file) where Entity : class,new()
    {
        var sysFile = await _fileService.UploadFile(file, FileConst.BatchImport);
        var columnList = UtilMethod.GetEntityMetadataToList<Entity>();
        var data = await ExcelImportHelper.ReadExcelToList<Entity>(Path.Combine(sysFile.EnginePath, sysFile.StoragePath), columnList);
        return data;
    }
}
